package com.wanhelibs.adapter;

import android.content.Context;
import android.view.View;

import com.wanhe.base.model.disgn.CatalogViewModel;
import com.wanhe.mealbookmodule.adapter.CommonAdapter;
import com.wanhelibs.indicator.CustomTab;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by cdj on 2017/8/1.
 */

public class IndicatorAdapter extends CommonAdapter<CatalogViewModel> {


    private Map<Integer, Integer> typePositionMap = new HashMap<>();

    public IndicatorAdapter(Context context) {
        super(context);
    }

    @Override
    protected View createCustomerView(int position) {
        CustomTab tab = new CustomTab(mContext);
//        tab.setPosition(position);
        CatalogViewModel viewModel = (CatalogViewModel) getItem(position);
        typePositionMap.put(viewModel.getId(), position);
        tab.bindDishType(viewModel.getId(), viewModel.getName());
        return tab;
    }

    @Override
    protected void bindViewData(View convertView, int position) {
        super.bindViewData(convertView, position);
    }

    /**
     * Methor Name:getTypePosition<br/>
     * Package Name:com.wanhelibs.adapter<br/>
     * Date:2017/8/1 16:23<br/>
     * author:chendeji<br/>
     * desc: 根据给出的类型id来找到具体的位置<br/>
     * Copyright (c) 2017/8/1, 781571323@qq.com All Rights Reserved.
     *
     * @param typeId tid
     * @return position
     * 
     */
    public int getTypePosition(int typeId){
        return typePositionMap.get(typeId);
    }
}
